package com.gitee.wsl.func.filter.bloomfilter.api

import com.gitee.wsl.func.filter.bloomfilter.bean.Shape


/**
 * A Hasher creates [IndexExtractor]s based on the hash implementation and the provided [Shape].
 *
 * @since 4.5.0-M1
 */
fun interface Hasher {
    /**
     * Creates an IndexExtractor for this hasher based on the Shape.
     *
     *
     *
     * The `IndexExtractor` will create indices within the range defined by the number of bits in the shape. The total number of indices will respect the
     * number of hash functions per item defined by the shape. However the count of indices may not be a multiple of the number of hash functions if the
     * implementation has removed duplicates.
     *
     *
     *
     *
     * This IndexExtractor must be deterministic in that it must return the same indices for the same Shape.
     *
     *
     *
     *
     * No guarantee is made as to order of indices.
     *
     *
     *
     * Duplicates indices for a single item may be produced.
     *
     *
     * @param shape the shape of the desired Bloom filter.
     * @return the iterator of integers
     */
    fun indices(shape: Shape): IndexExtractor
}
